<template>
  <div class="app-container">
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input v-model="assetId" placeholder="资产id" />
      </el-form-item>
      <el-button type="primary" icon="el-icon-search" @click="findAsset()">资产id查询</el-button>
    </el-form>

    <!-- banner列表 -->
    <el-table :data="assetObject" stripe style="width: 100%">
      <el-table-column type="index" width="50" label="序号" />
      <el-table-column prop="assetId" label="资产链上编号" />
      <el-table-column prop="assetName" label="资产名称" />
      <el-table-column prop="assetType" label="资产类型" />
      <el-table-column prop="assetValue" label="资产价值" />
      <el-table-column prop="assetDescription" label="具体描述" />
      <el-table-column prop="assetTerm" label="资产期限" />
      <el-table-column prop="createTime" label="创建时间" />
      <el-table-column prop="updateTime" label="更新时间" />
    </el-table>
  </div>
</template>

<script>
import asset from '@/api/asset'

export default {
  // 定义变量和初始值
  data() {
    return {
      assetId: '',
      assetObject: []
    }
  },
  created() {
  },
  methods: {
    findAsset() {
      asset
        .findAsset(this.assetId)
        .then((response) => {
          const temp = response.data
          temp.createTime = this.timeFormatConversion(temp.createTime)
          temp.updateTime = this.timeFormatConversion(temp.updateTime)
          const arr = []
          arr.push(temp)
          this.assetObject = arr
        }) // 请求成功
        .catch((error) => {
          console.log(error)
        }) // 请求失败
    },
    // 因为你时间传过来的是一个string，这里格式转换就是对字符串操作，如果你后端传过来格式是yyyy-mm-dd HH:MM:ss格式的就不用转换了
    timeFormatConversion(date) {
      return date.slice(0, 10) + ' ' + date.slice(11, 19)
    }
  }
}
</script>
